home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / reform15.zip / REFORMAT.PAS < prev   
Pascal/Delphi Source File  |  1987-05-23  |  22KB  |  542 lines

  1. (*
  2. To:  INFO-IBMPC-REQUEST@USC-ISIB.ARPA
  3. From:  U001222%HNYKUN11.BITNET@WISCVM.WISC.EDU
  4. Subject: reformat.pas
  5. *)
  6. PROGRAM reformat;
  7. {
  8.   Program to reformat any disk attached to an Olivetti PC or compatible.
  9.   The progam will work well on any MS/PC-DOS machine running under DOS
  10.   versions 2.00 up to and including 3.10. Fixed disks up to 32 Meg.
  11.  
  12.     V1.50 Extensions made for big FATs. WORD.INC included for handling of
  13.     word integers. MS-DOS function INT21 / 32H used for drive information.
  14.     Corrected the problem of DOS losing track of the current directory.
  15.  
  16.     The program has been tested under DOS 2.00 thru 3.10
  17.     It will probably work under DOS 3.20 too, but this version will not
  18.     run when you try to do so. If you want to test it with DOS 3.20, look
  19.     for the string DOS_Versions (it's somewhere near the end of the program)
  20.     in this program, and include that version number into the test.
  21.     Please let the author know whether you had success or not.
  22.  
  23.     Jos Wennmacker                                    July 86.
  24.     Universitair Rekencentrum
  25.     Geert Grooteplein Zuid 41
  26.     6525 GA Nijmegen
  27.     The Netherlands
  28.  
  29.     BITNET address: U015415 at HNYKUN22
  30.  
  31.     V1.5  Jos added new 16-bit and word code, handling up to 30Meg
  32.     hard disks, etc.  I cleaned up the integer math inline procedures
  33.     a little.
  34.     David Kirschbaum, Toad Hall
  35.  
  36.     V1.23 Added FRAMER.INC, WRITEF.INC for framing, fast screen write,
  37.     fast screen line clear.  Tightened up displays a little.
  38.     This version is now VERY PC-specific.  Generic MS-DOS functions
  39.     for screen stuff to follow.
  40.     David Kirschbaum, Toad Hall.
  41.  
  42.     V1.22 Added inline code to replace the INT25.ASM and INT26.ASM
  43.     files.
  44.     David Kirschbaum, Toad Hall, 3 May 86
  45.  
  46.     V1.21(mod) not publicly released. Changes made by Rick Watson to let
  47.     the program recognize the big (16 bit) FATs. He made it run on 20 Meggers
  48.     under DOS 3.x. Martin Hobson made it run on 30 Meggers under DOS 3.x.
  49.     May 86.
  50.  
  51.     V1.21 Small corrections made to avoid Turbo integer overflow. (Hey,
  52.     Borland, what about a WORD type in Turbo, would be very usefull using
  53.     the MSDOS features!).
  54.  
  55.     V1.20 First release to the public domain.
  56.     What started as a favour to a friend grew into a nice program.
  57.     Do you like it? Let me know about it! If I know many people to use it,
  58.     I'll keep it up to date, and send you new releases.
  59.     Jos Wennmacker
  60.  
  61. }
  62. {$C-}
  63. {-------------------------------- Global types -------------------------------}
  64.  
  65. TYPE
  66.  
  67. {------------------- types for word arithmetic  see REFORMAT.IN1 -------------}
  68.  
  69.   word                =      INTEGER;
  70.  
  71.   Relational_Operator =      (Eq, Gt, Lt, Ne, Ge, Le);
  72.  
  73. {------------------------ for interrupts and DOS calls -----------------------}
  74.  
  75.   Regpack             =
  76.     RECORD CASE INTEGER OF
  77.       1: (ax, bx, cx, dx, bp, si, di, ds, es, flags : word);
  78.       2: (al, ah, bl, bh, cl, ch, dl, dh            : Byte);
  79.     END;
  80.  
  81. {----------------------------- Bootrecord layout -----------------------------}
  82.  
  83.   Boot                =                { the layout of the DOS boot record    }
  84.     RECORD
  85.       Jump:                  ARRAY[0..2] OF Byte; { Near jump to boot code    }
  86.       OEM :                  ARRAY[0..7] OF CHAR; { eight character OEM name  }
  87.       sectorSize:            word;     { number of bytes in one sector        }
  88.       clusterSize:           Byte;     { sectors per cluster                  }
  89.       reservedSectors:       word;     { DOS boot code sector(s) typically 1  }
  90.       numberOfFATs:          Byte;     { usually 2, but often 1 for RAM disks }
  91.       rootDirSize,                     { maximum entries in root directory    }
  92.       totalSectors:          word;     { total sectors in the logical image   }
  93.       mediaDescriptor:       Byte;     { A limited description of the drive
  94.                                          bit 0 = 1: twosided, 0: not two-sided
  95.                                          bit 1 = 1: 8-sector, 0: not 8-sector
  96.                                          bit 2 = 1: removable 0: not removable
  97.                                          bits 3-7 must be set to 1            }
  98.       fatSize,                         { number of sectors in each FAT copy   }
  99.       trackSize,                       { number of sectors per track          }
  100.       numberOfHeads,                   { number of heads                      }
  101.       hiddenSectors:         word;     { sectors hidden from DOS, preceding
  102.                                          the DOS partition: including the
  103.                                          master boot record and any non-DOS
  104.                                          partitions                           }
  105.     END;
  106.  
  107. {---------------- Layout of DOS function 32h disk parameter block ------------}
  108.  
  109.   Parms_32            =     ^Parameter_table;
  110.  
  111.   Parameter_Table     =                { layout of the DOS function 32 table  }
  112.     RECORD
  113.       assignedDisk,                    { 0 = A, 1 = B, ...                    }
  114.       altAD:                 Byte;     { same as above, but 0 for RAM disk    }
  115.       sectorSize:            word;     { number of bytes in one sector        }
  116.       clusterSize_1,                   { sectors per cluster minus 1          }
  117.       numberOfHeads_1:       Byte;     { number of heads minus 1              }
  118.       reservedSectors:       word;     { DOS boot code sector(s) typically 1  }
  119.       numberOfFATs:          Byte;     { usually 2, but often 1 for RAM disks }
  120.       rootDirSize,                     { maximum entries in root directory    }
  121.       firstDataSector,                 { first sector for data storage        }
  122.       totalDataClusters_1:   word;     { total data clusters plus 1           }
  123.       fatSize:               Byte;     { number of sectors in each FAT copy   }
  124.       firstDirectorySector:  word;     { first sector of the root directory   }
  125.       DeviceDriverAddress:  ^byte;     { Far (offset, segment) address of the
  126.                                          DOS device driver for the drive      }
  127.       mediaDescriptor:       word;     { A limited description of the drive
  128.                                          only the low order byte is used:
  129.                                          bit 0 = 1: twosided, 0: not two-sided
  130.                                          bit 1 = 1: 8-sector, 0: not 8-sector
  131.                                          bit 2 = 1: removable 0: not removable
  132.                                          bits 3-7 must be set to 1            }
  133.       NextParameterTable:    Parms_32; { far pointer to next disk table       }
  134.       currentDirCluster:     word;     { Starting cluster of current working
  135.                                          directory. According to Glenn Roberts
  136.                                          in his May 86 PC Tech Journal article
  137.                                          "Finding Disk Parameters" this would
  138.                                          only hold for PC DOS 2.00
  139.                                                                               }
  140.       CurrentDirName:        ARRAY [0..63] OF CHAR
  141.                                        {
  142.                                          The name of the current working
  143.                                          directory. This does not hold for
  144.                                          DOS 3.x versions. Only for 2.00      }
  145.     END;
  146.  
  147. {-------- Long byte and integerarays for Disk Transfer Area, Fats etc. -------}
  148.  
  149.   intArray   = ARRAY[0..32766] OF INTEGER;
  150.  
  151.   buffer     = ARRAY[0..32766] OF Byte;
  152.  
  153. {--------------------- Element of tree of directory entries ------------------}
  154.  
  155.   DirectoryPointer = ^DirectoryEntry;
  156.  
  157.   longInteger      = ARRAY[0..1] OF INTEGER;
  158.  
  159.   DirectoryEntry =
  160.     RECORD
  161.       EntryName:          ARRAY[0..10] OF CHAR; { name + extension w/o period
  162.                                          If the first char is $00 then this
  163.                                          entry was never used. Also the next
  164.